package com.kevin.ymqquan.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.kevin.ymqquan.R;
import com.kevin.ymqquan.bean.ClubConUser;
import com.kevin.ymqquan.bean.CourseUserList;

public class CourseUserAdapter extends BaseAdapter {

	private List<CourseUserList> clubUserList;
	private LayoutInflater lf;

	public CourseUserAdapter(Activity mContext,
			List<CourseUserList> clubUserList) {
		this.clubUserList = clubUserList;
		lf = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return clubUserList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ClubUserHolder holder = new ClubUserHolder();
		if (convertView == null) {
			convertView = lf.inflate(R.layout.list_courseuser_item, parent,
					false);
			holder.tv_clubconuser_item_consume = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_xb);
			holder.tv_clubconuser_item_yearcard = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_sf);
			holder.tv_clubconuser_item_balancecard = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_join);
			holder.tv_clubconuser_item_username = (TextView) convertView
					.findViewById(R.id.tv_clubconuser_item_username);
			convertView.setTag(holder);
		} else {
			holder = (ClubUserHolder) convertView.getTag();
		}

		holder.tv_clubconuser_item_consume.setText("性别:"
				+ clubUserList.get(position).getUserSex() + "");
		holder.tv_clubconuser_item_yearcard.setText("身份:"
				+ clubUserList.get(position).getUserStatus());
		holder.tv_clubconuser_item_balancecard.setText("1".equals(clubUserList
				.get(position).getIsJoin()) ? "已加入" : "未加入");
		holder.tv_clubconuser_item_username.setText(clubUserList.get(position)
				.getUserName());

		return convertView;

	}

	/**
	 * 自定义控件集合
	 */
	public static class ClubUserHolder {
		// 消费金额
		public TextView tv_clubconuser_item_consume;
		// 限时卡
		public TextView tv_clubconuser_item_yearcard;
		// 预存卡
		public TextView tv_clubconuser_item_balancecard;
		// 用户名
		public TextView tv_clubconuser_item_username;
	}

}
